package io.narayana.txdemo.jms;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.util.Properties;

/**
 * @author machinly
 * @date 16/4/21
 * @mail machinly@outlook.com
 */
public class WildFlyJmsQueue {

    public static InitialContext getInitialContext() throws NamingException {
        InitialContext context = null;
        final Properties env = new Properties();
        env.put(Context.INITIAL_CONTEXT_FACTORY, QueueConst.JMS_CONTEXT_FACTORY);
        env.put(Context.PROVIDER_URL, QueueConst.WILDFLY_REMOTING_URL);
        env.put(Context.SECURITY_PRINCIPAL, QueueConst.JMS_USERNAME);
        env.put(Context.SECURITY_CREDENTIALS, QueueConst.JMS_PASSWORD);
        //props.put("jboss.naming.client.ejb.context", true);
        context = new InitialContext(env);
        System.out.println("\n\tGot initial Context: " + context);
        return context;
    }
}
